package com.cham.danmu.mapper;

import com.cham.danmu.dto.DanmuShootAndCollectDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Howl-Xu
 * @version 1.0.0
 * @Description: 请描述一下这个类文件吧
 * @createTime 2020年03月31日 12:32:00
 */
public interface DanmuMapper {
    @Insert("insert into cham_danmu(video_id,danmu_content,danmu_color,slider_value,top,danmu_delay,danmu_create_date) VALUES (#{videoId},#{danmuContent},#{danmuColor},#{sliderValue},#{top},#{danmuDelay},#{danmuCreateDate})")
    void danmuShoot(DanmuShootAndCollectDTO danmuShootDTO);

    @Select("select * from cham_danmu where video_id = #{videoId} and slider_value = #{sliderValue}")
    List<DanmuShootAndCollectDTO> danmuCollect(DanmuShootAndCollectDTO danmuCollectDTO);

    @Select("select cd.* from cham_danmu cd where video_id = #{videoId} order by cd.danmu_create_date desc limit 1000")
    List<DanmuShootAndCollectDTO> getTop1000DanmuByVideoId(int videoId);

    @Select("select count(1) from cham_danmu cd where cd.video_id = #{videoId}")
    int getDanmuTotalByVideoId(int videoId);
}
